//
//  NSMutableArray+Tools.h
//  MiaoPai
//
//  Created by jiaxuzhou on 2017/6/10.
//  Copyright © 2017年 Jeakin. All rights reserved.
//
//


#import <Foundation/Foundation.h>
#import "NSObject+Tools.h"


/// 数组保护
/// 是否NSMutableArray类型
#define MPT_mAry_Class(mary) MPT_Object_Is_Class(mary,[NSMutableArray class])

/// 是否有效，不为空，且是NSMutableArray类型，且count值大于0
#define MPT_mAry_Is_Valid(mary) ((MPT_Object_Not_Null(mary)) && (MPT_mAry_Class(mary)) && ([mary count] > 0))

/// 是否有效，不为空，且是NSMutableArray类型，没元素也是有效数组
#define MPT_mAry_Is_Valid_ExceptEmpty(mary) ((MPT_Object_Not_Null(mary)) && (MPT_mAry_Class(mary)))

/// 是否无效，或为空，或不是NSMutableArray类型，或count值小于等于0
#define MPT_mAry_Not_Valid(mary) ((MPT_Object_Is_Null(mary)) || !(MPT_mAry_Class(mary)) || ([mary count] <= 0))

/// 是否无效，或为空，或不是NSMutableArray类型
#define MPT_mAry_Not_Valid_ExceptEmpty(mary) ((MPT_Object_Is_Null(mary)) || !(MPT_mAry_Class(mary)))

/// 获取数组index下的数据

#define MPT_mAry_GetValidObjectFromArray(array,index) mp_getValidObjectForArray(array,index)

/// 删除数组元素保护
#define MPT_mAry_RemoveValidObjectFromArray(array,index) mp_removeValidObjectFromArray(array,index)

/// 添加数组元素保护
#define MPT_mAry_AddValidObjectForArray(array,value) mp_addValidObjectForArray(array,value)

/// 数组中添加数组保护
#define MPT_mAry_AddValidArrayForArray(array,value) mp_addValidArrayForArray(array,value)

/// 替换数组元素保护
#define MPT_mAry_ReplaceValidObjectForArray(array,index,value) mp_replaceValidObjectForArray(array,index,value)

/// 插入数组元素保护
#define MPT_mAry_InsertValidObjectForArray(array,index,value) mp_insertValidObjectForArray(array,index,value)

@interface NSMutableArray (Tools)


/**
 以下方法禁止在外部调用

 void mp_removeValidObjectFromArray(NSMutableArray *array, NSInteger index);
 void mp_addValidObjectForArray(NSMutableArray *array, id value);
 void mp_addValidArrayForArray(NSMutableArray *array, NSArray *value);
 void mp_replaceValidObjectForArray(NSMutableArray *array, NSInteger index, id value);
 BOOL mp_insertValidObjectForArray(NSMutableArray *array, NSInteger index, id value);
 */
id mp_getValidObjectForArray(NSMutableArray *array, NSInteger index);
void mp_removeValidObjectFromArray(NSMutableArray *array, NSInteger index);
void mp_addValidObjectForArray(NSMutableArray *array, id value);
void mp_addValidArrayForArray(NSMutableArray *array, NSArray *value);
void mp_replaceValidObjectForArray(NSMutableArray *array, NSInteger index, id value);
void mp_insertValidObjectForArray(NSMutableArray *array, NSInteger index, id value);


@end
